package tsing.javase.thread.pool.pratice;

import java.util.concurrent.*;

/**
 * @Date 2024/2/8 10:16
 */
public class ThreadDemo2 {
    public static void main(String[] args) {


        CountDownLatch threadSignal = new CountDownLatch(100);

        ExecutorService executorService = new ThreadPoolExecutor(100, 200, 10L,
                TimeUnit.MINUTES, new LinkedBlockingQueue<Runnable>(), new ThreadPoolExecutor.CallerRunsPolicy());

        for (int i = 0; i <100 ; i++) {
            ThreadDemo thread = new ThreadDemo(threadSignal);
            executorService.execute(thread);
        }

        //等待多线程处理完
        executorService.shutdown();
        try {
            executorService.awaitTermination(10L, TimeUnit.MINUTES);
        } catch (InterruptedException e) {

        }

    }
}
